<%@page import="java.util.ArrayList"%>
<%@page import="entity.PhotoEntity"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>修改商品信息</title>
<!-- 用于转跳之后的路径恢复 -->
<%
	String path = request.getRequestURI();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<base href="<%=basePath%>">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/adminStyle.css" rel="stylesheet" type="text/css" />
</head>
<body>
<c:set var="good" value="${good }"></c:set>
<c:set value="${type }" var="type"></c:set>
<c:set var="way" value="${way }"></c:set>
<c:set var="imgParId" value="${imgParId }"></c:set>
 <div class="wrap">
  <div class="page-title">
    <span class="modular fl"><i class="add"></i><em>编辑/添加产品</em></span>
    <span class="modular fr"><a class="pt-link-btn" onclick="javascript:window.history.back();">产品列表</a></span>
  </div>
  <form action="../Update?op=UpdateGood&goodId=${good.goodId }" method="post" enctype="multipart/form-data">
  <table class="list-style">
   <tr>
    <td style="text-align:right;width:15%;">产品名称：</td>
    <td><input type="text" class="textBox length-long" name="name" value="${good.goodName }"/></td>
   </tr>
   <tr>
    <td style="text-align:right;">产品分类：</td>
    <td>
     <select class="textBox" name="selectName">
      <option value="${type =='小米手机'?'小米手机':'红米手机'}" selected="selected">${type =='小米手机'?'小米手机':'红米手机'}</option>
      <option value="${type =='红米手机'?'小米手机':'红米手机'}" >${type =='红米手机'?'小米手机':'红米手机'}</option>
     </select>
    </td>
   </tr>
   <tr>
    <td style="text-align:right;">标配价：</td>
    <td>
     <input type="text" class="textBox length-short" name="price" id="price" onInput ="keypress(this)" value="${good.goodPrice }"/>
     <span>元</span>
    </td>
   </tr>
   <!-- 版本 -->
    <c:forEach items="${parameterList }" var="parameterList">
    <c:if test="${parameterList.fparId=='par001'}">
   <tr>
    <td style="text-align:right;width:15%;">版本：</td>
    <td>
    <input type="text" class="textBox length-long" name="editionId" value="${parameterList.parId }" style="display: none;"/>
    <input type="text" class="textBox length-long" name="edition" value="${parameterList.parName }"/>
    </td>
   </tr>
   </c:if>
   </c:forEach>
   <!-- 套餐 -->
   <c:forEach items="${parameterList }" var="parameterList">
    	<c:if test="${parameterList.fparId=='par003'}">
   <tr>
    <td style="text-align:right;width:15%;">套餐：</td>
    <td>
    <input type="text" class="textBox length-long" name="setmealId" value="${parameterList.parId }" style="display: none;"/>
    <input type="text" class="textBox length-long" name="setmeal" value="${parameterList.parName }"/>
    </td>
   </tr>
   </c:if>
   </c:forEach>
   
   <tr>
    <td style="text-align:right;">产品缩图片：</td>
    <td>
    <input type="text" class="textBox length-long" name="img1Id" value="${imgParId }" style="display: none;"/>
     <input type="file" id="suoluetu" class="hide" onchange="showImg(this)" name="img1"/>
     <label for="suoluetu" class="labelBtnAdd">+</label>
     <img src="${way }" width="140px" height="90px" class="mlr5" id="imgaa"/>
    </td>
   </tr>
   
<%--   <!-- 颜色名称 -->
  <c:forEach items="${parameterList }" var="parameterList" varStatus="loop">
     	<c:if test="${parameterList.fparId=='par002' }">
    <tr style="display: none;">
    <td style="text-align:right;width:15%;">颜色：</td>
    <td>
   
    <input type="text" class="textBox length-long" name="color" value="${parameterList.parName }"/>
    </td>
   </tr> 
   </c:if>
   </c:forEach> --%>
   
   <!-- 颜色图片 -->
   <c:forEach items="${photoList }" var="photolist">
   <tr>
    <td style="text-align:right;">颜色图：</td>
    <td>
     <input type="text" class="textBox length-long" name="colorId" value="${photolist.photoId }" style="display: none;"/>
     <input type="file"  id="chanpinzhutu" class="hide" onchange="showImg2(this)" name="img2"/>
     <label for="chanpinzhutu" class="labelBtn2" >本地上传</label>
      <img src="${photolist.way }" width="130px" height="110px" id="imgb"/>
      
    </td>
   </tr>
   </c:forEach>
   
   <tr>
    <td style="text-align:right;">产品详情：</td>
    <td><textarea class="textarea" name="details">${good.goodIntroduce }</textarea></td>
   </tr>
   <tr>
    <td style="text-align:right;"></td>
    <td><input type="submit" value="确认修改" class="tdBtn"/></td>
   </tr>
  </table>
  </form>
 </div>

	<script type="text/javascript">
    function showImg(input) {
        var file = input.files[0];
        var reader = new FileReader()
        // 图片读取成功回调函数
        reader.onload = function(e) {
            document.getElementById('imgaa').src=e.target.result
        }
        reader.readAsDataURL(file)
    }

    function showImg2(input) {
        var file = input.files[0];
        var reader = new FileReader()
        // 图片读取成功回调函数
        reader.onload = function(e) {
            document.getElementById('imgb').src=e.target.result
        }
        reader.readAsDataURL(file)
    }

   
    function keypress(_this){
        _this.value = _this.value.replace(/[^0-9]/g, '');
    }
    
</script>

</body>
</html>